#! /usr/bin/env python
#coding=utf-8
def sendEmail(title='',content=''):
    from email.mime.text import MIMEText
    from email.header import Header
    from smtplib import SMTP_SSL#qq邮箱smtp服务器
    host_server = 'smtp.qq.com'#sender_qq为发件人的qq号码
    sender_qq = 'buaa1714iot@qq.com'#pwd为qq邮箱的授权码
    pwd = 'spocsbywdfmvdgid' ## xh**********bdc#发件人的邮箱#spocsbywdfmvdgid
    sender_qq_mail = 'buaa1714iot@qq.com'#收件人邮箱
    receiver = '1295752786@qq.com'#邮件的正文内容
    mail_content = content#'你好，这是使用python登录qq邮箱发邮件的测试'#邮件标题
    mail_title = title#'Maxsu的邮件'#ssl登录
    smtp = SMTP_SSL(host_server)#
    #set_debuglevel()是用来调试的。参数值为1表示开启调试模式，参数值为0关闭调试模式
    smtp.set_debuglevel(1)
    smtp.ehlo(host_server)
    smtp.login(sender_qq, pwd)

    msg = MIMEText(mail_content, "plain", 'utf-8')
    msg["Subject"] = Header(mail_title, 'utf-8')
    msg["From"] = sender_qq_mail
    msg["To"] = receiver
    smtp.sendmail(sender_qq_mail, receiver, msg.as_string())
    smtp.quit()
def passwordHash():
    # 导入密码加密模块
    import hashlib
    # 1.创建一个hash对象
    h = hashlib.sha256()
    # 2.填充要加密的数据
    passwordstr = '123456'
    h.update(bytes(passwordstr, encoding='utf-8'))
    # 3.获取加密结果
    pawd_result = h.hexdigest()
    print(pawd_result)
if __name__ =='__main__':
    sendEmail('危险！温度过高！','当前恒温箱温度%d度'%(47))
    # passwordHash()